package com.example.administrator.a0018testokhttp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

public class MainActivity extends AppCompatActivity {
   // private String body;
    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = findViewById(R.id.tv);
        OkGo.<String>get("http://www.qq.com")
                .tag(this)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                       //Toast.makeText(MainActivity.this,response.body(),Toast.LENGTH_LONG);

                        tv.setText(response.body());

                    }
                    @Override
                    public void onError(Response<String> response) {

                    }
                });
//        Toast toast = Toast.makeText(this,"asdf",Toast.LENGTH_LONG);
//       toast.show();

    }
}
